#!/usr/bin/env python2.7
#-*- coding=utf-8 -*-

from ..cstructures import BigendCStruct
from .base import NetworkData

def _formatmac_(data):
    return ':'.join(['%02x' % byt for byt in data])

class Ethernet(NetworkData):
    def __init__(self, data):
        super(Ethernet, self).__init__(data)
        self.nextlayer = self.type

    def formatmac(self):
        src = _formatmac_(self.srcmac)
        dst = _formatmac_(self.dstmac)
        return src, dst

    _fields_ = [
            ('dstmac', 'uByte', 6),
            ('srcmac', 'uByte', 6),
            ('type', 'WORD'),
        ]

layerdict = {
        1:Ethernet
    }
